package JDBC;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

public class JDBCDemo7 {
    public static void main(String[] args) {
        //userinfo userinfo = InputUtil.getInputObject(new userinfo(),"欢迎登录","登录");*/
        String username = "admin";
        String password = "123456";
        try (Connection con = DBUtil.getConnection();){
            Statement sta = con.createStatement();
            String sql = "SELECT id , username , password , nickname ,age " +
                    "FROM userinfo " +
                    "WHERE username=? AND password =?";
            PreparedStatement ps = con.prepareStatement(sql);
            ps.setString(1,username);
            ps.setString(2,password);
            ResultSet rs = ps.executeQuery();
            if(rs.next()){
                System.out.println("登陆成功");
            }else {
                System.out.println("登陆失败");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
